package com.liao.healthydiet.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import com.liao.healthydiet.R;
import com.liao.healthydiet.domain.Food;
import com.liao.healthydiet.utils.GetData;

public class FoodDetailActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_back;
    private TextView tv_food_name;
    private ImageView img_food_img;
    private TextView tv_food_name1;
    private TextView tv_food_detail;
    private TextView tv_food_collocation;

    private Food food;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food_detail);
        initView();
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        Intent intent = getIntent();
        food = (Food) intent.getSerializableExtra("food");
        initData();
    }

    private void initView() {
        btn_back = (Button) findViewById(R.id.btn_back);
        tv_food_name = (TextView) findViewById(R.id.tv_food_name);
        img_food_img = (ImageView) findViewById(R.id.img_food_img);
        tv_food_name1 = (TextView) findViewById(R.id.tv_food_name1);
        tv_food_detail = (TextView) findViewById(R.id.tv_food_detail);
        tv_food_collocation = (TextView) findViewById(R.id.tv_food_collocation);

        btn_back.setOnClickListener(this);
    }

    private void initData() {
        tv_food_name.setText(food.getName());
        tv_food_name1.setText(food.getName());
        img_food_img.setImageResource(food.getImage());
        tv_food_detail.setText(food.getDetail());
        tv_food_collocation.setText(food.getCollocation());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_back:
                onBackPressed();
                break;
        }
    }
}
